namespace OFX.Aggregator.WpfApplication
{
	using System;
	using System.Diagnostics;

	using Infrastructure;

	public class ProgressReportBridge : IProgressReport
	{
		private IProgressReport progressReport;

		#region Implementation of IProgressReport

		public void OnProgress(double currentStep, double totalSteps) { this.progressReport.OnProgress(currentStep, totalSteps); }

		public void OnFinish()
		{
			Debug.Assert(this.progressReport != null);

			this.progressReport.OnFinish();

			SetPage(null);
		}

		public void ReportError(Exception ex)
		{
			Debug.Assert(this.progressReport != null);

			this.progressReport.ReportError(ex);

			SetPage(null);
		}

		#endregion

		public void SetPage(IProgressReport page) { this.progressReport = page; }
	}
}